import {createApp} from 'vue'
import App from './App.vue'
import {router} from './router/index'

// router.beforeEach((to, from, next) => {
//     let white = ['/login']
//     if (white.indexOf(to.path) >= 0) {
//         next()
//     } else {
//         // 获取到此用户的资源列表
//         let pagelist = localStorage.getItem('pagelist')
//         if (pagelist) {
//             let reslist = JSON.parse(pagelist)
//             if (reslist.indexOf(to.path) >= 0) {
//                 next()
//             }
//         }else {
//             alert('您无权访问')
//             return false;
//         }
//     }
// })


import axios from 'axios'
import qs from 'qs'


import Vant from 'vant';
import 'vant/lib/index.css';


import element from 'element-plus'
import 'element-plus/dist/index.css'


//封装请求
const myaxios = function (url, type, data = {}) {

    return new

    Promise((resolve) => {


        //判断
        if (type === "get" || type === "delete") {


            axios({

                method: type,
                url: url,
                params: data
            }).then((result) => {

                resolve(result.data);

            });


        } else {


            axios({

                method: type,
                url: url,
                data: qs.stringify(data)
            }).then((result) => {

                resolve(result.data);

            });


        }


    });


}


const app = createApp(App)

axios.defaults.baseURL = 'https://localhost:5000/'
app.config.globalProperties.axios = axios;
app.config.globalProperties.myaxios = myaxios;
app.config.globalProperties.upload_dir = "https://localhost/static/";

app.use(router);
app.use(Vant);
app.use(element)

app.mount('#app')
